package com.zhuojy.equity.mall.admin.common.exception;

import com.zhuojy.equity.mall.admin.common.enums.ErrCdEnum;

import org.springframework.security.core.userdetails.UsernameNotFoundException;

/**
 * 断言处理类，用于抛出各种BizException
 */
public class Asserts {

	/**
	 * 防止类被实例化
	 */
	private Asserts() {
		throw new IllegalAccessError("Utility class");
	}

	/**
	 * 根据错误描述抛异常
	 */
	public static void fail(String message) {
		throw new BizException(ErrCdEnum.B001.getCode(), message);
	}

	/**
	 * 根据错误码枚举对象抛异常
	 */
	public static void fail(ErrCdEnum errCd) {
		throw new BizException(errCd.getCode(), errCd.getDesc());
	}

	/**
	 * 抛 UsernameNotFoundException
	 */
	public static void UsernameNotFoundException() {
		throw new UsernameNotFoundException("用户名错误!");
	}
}
